
#include <avr/io.h>
#include "adc.h"

void adc_init(void){
	
	ADCSRA |= (1 << ADEN);	//Enable ADC
	ADMUX |= (6 << MUX0)|(3 << REFS0);	//Select light sensor as input, set voltage reference 
	//ADMUX |= (1 << ADLAR);	//Enable left adjust

}

uint16_t adc_read(void){

	uint16_t adc_value = 0;
	ADCSRA |= (1 << ADSC);	//Start conversion	
	while(!(ADCSRA & (1 << ADIF))){}	//Wait until conversion is complete
	adc_value = ADC;
	return adc_value;
}
